USE [master]
GO

IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = 'itunespwned')
CREATE DATABASE [itunespwned]
	ON 
	( 
		FILENAME = '$(DBINSTDIR)\itunespwned.mdf' 
	)
	LOG ON 
	( 
		FILENAME = '$(DBINSTDIR)\itunespwned_log.ldf' 
	)
	FOR ATTACH;
GO

USE [itunespwned]
GO

IF NOT EXISTS(SELECT * FROM sys.tables WHERE name = 'library')
	CREATE TABLE [dbo].[library] 
	(
		[guid] [varchar](50) NOT NULL,
		[persishigh] [int] NOT NULL,
		[persislow] [int] NOT NULL,
		[name] [varchar](100) NOT NULL PRIMARY KEY,
		[artist] [varchar](50) NULL,
		[album] [varchar](50) NULL,
		[genre] [varchar](50) NULL,
		[kind] [varchar](50) NULL,
		[tracknumber] [int] NULL,
		[year] [int] NULL,
		[bitrate] [int] NULL,
		[duration] [int] NULL,
		[size] [int] NULL,
		[artwork] [int] NULL,
		[location] [varchar](max) NULL,
	)
GO

IF NOT EXISTS(SELECT * FROM sys.tables WHERE name = 'settings')
	CREATE TABLE [dbo].[settings] 
	(
		[identifier] [varchar](50) NOT NULL PRIMARY KEY,
		[value] [varchar](max) NULL,
	)
GO